import junit.framework.TestCase;
import org.junit.Test;

public class StringBufferDemoTest extends TestCase {
    StringBuffer a = new StringBuffer("StringBuffer");
    //测试12个字符
    StringBuffer b = new StringBuffer("StringBufferStringBuffer");
    //测试24个字符
    StringBuffer c = new StringBuffer("StringBufferStringBufferStringBuffer");
    //测试36个字符
    StringBuffer d = new StringBuffer("StringBufferStringBufferStringBufferStr");
    //测试39个字符
    @Test
    public void testcharAt() {
        assertEquals('S',a.charAt(0));
        assertEquals('n',b.charAt(16));
        assertEquals('B',c.charAt(18));
    }

    @Test
    public void testindexOf() {
        assertEquals(0,a.indexOf("Str"));
        assertEquals(3,b.indexOf("ing"));
        assertEquals(6,c.indexOf("Buffer"));
        assertEquals(8,d.indexOf("ff"));
    }
    @Test
    public void testlength() {
        assertEquals(12,a.length());
        assertEquals(24,b.length());
        assertEquals(36,c.length());
        assertEquals(39,d.length());
    }

}
